package lol.clann.bukkit.pluginboot.model;

import lol.clann.bukkit.pluginboot.service.ServerTick;
import lol.clann.clannboot.annotation.inject.Inject;
import lol.clann.clannboot.context.BeanContext;

/**
 * @author pyz
 * @date 2018/10/1 下午9:09
 */
public class BukkitCooldown {

    private final long interval;

    private long last = 0;

    private long next = 0;

    @Inject
    private ServerTick serverTick;

    public BukkitCooldown(long interval) {
        BeanContext.inject(this);
        this.interval = interval;
    }

    public void mark() {
        last = serverTick.getTick();
        next = last + interval;
    }

    public boolean isCooldown() {
        return next <= serverTick.getTick();
    }

}
